import { createApp } from 'vue'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import App from './App.vue'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import pinia from './store'
import { zhCn } from 'element-plus/es/locales.mjs'
import router from './router'
import './styles/index.scss'
import './permission'
import 'element-plus/theme-chalk/dark/css-vars.css'
import  useSettingStore  from './store/modules/setting'


const app = createApp(App)
app.use(pinia)

const settingStore = useSettingStore()

document.documentElement.classList.toggle('dark', !settingStore.isLight)
settingStore.$subscribe((mutation, state) => {
  document.documentElement.classList.toggle('dark', !state.isLight)
})

for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}
app.use(ElementPlus, {
  locale: zhCn,
})
app.use(router)

app.mount('#app')